#include "hal_leds.h"


#define LED1		P27
#define LED2		P26
#define LED3		P15
#define LED4		P14
#define LED5		P23
#define LED6		P22
#define LED7		P21
#define LED8		P20
#define LED_SW		P45

static void GPIO_Config() {
    P4_MODE_IO_PU(GPIO_Pin_5);
	P2_MODE_IO_PU(GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_6 | GPIO_Pin_7);
	P1_MODE_IO_PU(GPIO_Pin_4 | GPIO_Pin_5);
    LED_SW = 0;
}

void HAL_Leds_Init(void) {
    GPIO_Config();
    LED1 = LED2 = LED3 = LED4 = LED5 = LED6 = LED7 = LED8 = OFF;
}

//灯组的基本亮灭
void HAL_Leds_Control(Leds_Position_t leds, char state) {
    switch (leds) {
        case LEDS1:
            LED1 = state ? ON : OFF;
            break;
        case LEDS2:
            LED2 = state ? ON : OFF;
            break;
        case LEDS3:
            LED3 = state ? ON : OFF;
            break;
        case LEDS4:
            LED4 = state ? ON : OFF;
            break;
        case LEDS5:
            LED5 =state ? ON : OFF;
            break;
        case LEDS6:
            LED6 = state ? ON : OFF;
            break;
        case LEDS7:
            LED7 = state ? ON : OFF;
            break;
        case LEDS8:
            LED8 = state ? ON : OFF;
            break;
    }
}